Click here to hard reload the page

* Data is preserved in the event of accidental browser refresh or browser crash (later is FF3.5 only)
Failed to connect to the database!
>>Please check the parameters and database server<<

'); $db_name="users"; $result=mysql_select_db($db_name); if(!$result){ setup(); } $a=0; if (isset( $_GET['type'])&& $_GET['type']=='login'){ if ($_POST['username']) { //did they supply a password and username $username=$_POST['username']; $password=$_POST['password']; if ($password==NULL) { echo "The password was not supplied"; }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($query); if($data['password'] != $password) { echo "The supplied login is incorrect"; }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $row = mysql_fetch_array($query); setcookie("user", "$username", time()+3600); login("The login was successful."); } } }else echo 'The username was not supplied'; }elseif (isset( $_GET['type'])&& $_GET['type']=='viewuser'){ $username=$_GET['user']; $query=mysql_query("select * from users where username='$username'") or die('An Errorr Occured'); $row = mysql_fetch_array($query)or die('An Errorr Occured'); $fullname=$row['fullname']; $city=$row['city']; $country=$row['country']; $interests=$row['interests']; $shout=$row['shout']; die( '
Shout: '.$shout.'
Full Name: '.$fullname.'
City: '.$city.'
Country: '.$country.'
Interests: '.$interests.'
PHP Free Code
'); }elseif (isset( $_GET['type'])&& $_GET['type']=='register'){ if (isset($_POST["username0"])) { $username = $_POST["username0"]; $password = $_POST["password0"]; $cpassword = $_POST["cpassword"]; $email = $_POST["email"]; //Was a field left blank? if($username==NULL||$password==NULL||$cpassword==NULL||$email==NULL) { echo "A field was left blank."; }else{ //Do the passwords match? if($password!=$cpassword) { echo "Passwords do not match"; }else{ //Has the username or email been used? $checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); $username_exist = mysql_num_rows($checkuser); $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); $email_exist = mysql_num_rows($checkemail); if ($email_exist||$username_exist) { echo "The username or email is already in use"; }else{ //Everything seems good, lets insert. $query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')"; mysql_query($query) or die(mysql_error()); login( "The user $username has been successfully registered."); } } } } }elseif (isset( $_GET['type'])&& $_GET['type']=='logout'){ setcookie("user", "", time()-3600); $a=1; } if (isset($_COOKIE['user']) && $_COOKIE['user']!="") { $username= $_COOKIE['user']; if ($a==0)login ("You have already logged in; Enjoy."); } $row1 = mysql_query("SELECT * FROM users");// ORDER BY uid DESC LIMIT 1") or die(mysql_error()); while($row=mysql_fetch_array($row1)) { $lastuser= $row['username']; } function setup(){ echo('

-Automatic setup is started...

'); global $host,$username,$password,$link; //$link=mysql_connect($host, $username, $password); $sql= 'CREATE DATABASE users'; if (!mysql_query ($sql, $link)) die('

Failed to create database!
>>Please check the parameters and database server<<

'); $sql = "CREATE TABLE `users`.`users` ( `username` TEXT NOT NULL , `password` TEXT NOT NULL , `email` TEXT NOT NULL, `shout` LONGTEXT NOT NULL, `fullname` TEXT NOT NULL, `city` TEXT NOT NULL, `country` TEXT NOT NULL, `interests` LONGTEXT NOT NULL ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;"; mysql_query($sql) or die('Setup Failed'); echo('

-Automatic setup completed successfully. Your Login-Registration system is ready!

'); } function login($msg){ global $username; $shout='';$country='';$city='';$intrests='';$fullname='';$interests=''; if (isset($_POST['Submit']) && $_GET['type']=='update'){ $fullname=$_POST['fullname']; $city=$_POST['city']; $country=$_POST['country']; $interests=$_POST['interests']; $shout=$_POST['shout']; $username=$_GET['user']; $sql=" UPDATE `users`.`users` SET `shout` = '$shout', `fullname` = '$fullname', `city` = '$city', `country` = '$country', `interests` = '$interests' WHERE `users`.`username` = '$username' ; mysql_query($sql) or die('Update Failed'); ";} $query=mysql_query("select * from users where username='$username'") or die('An Errorr Occured'); $row = mysql_fetch_array($query)or die('An Errorr Occured'); $fullname=$row['fullname']; $city=$row['city']; $country=$row['country']; $interests=$row['interests']; $shout=$row['shout']; $username=$row['username']; die('
'.$msg.' Shout:
Welcome '.$username.'
Logout

Full Name:
City:
Country:
Interests:
PHP Free Code
'); } ?>

Login

Username:
Password:

All Members:
'.$row['username'].'
'; } ?>

Register

Username:
Password:
Confirm Password:
Email:

Last member:

PHP Free Code
HTML Best Codes

Teya Salat